<?php
	
	session_start();
	require("connect.php");
	$link = connect_APO();
		
	if ($_SESSION['user'] == ('bro-pledge' || null)){
	}	

	require("check.php");
	is_logged_in();
	is_admin();
	
	require("header+logoutB.php");
	headerL();
	
	$num = $_SESSION['addCredNum'];
	
	echo "<html>
<body class='main'>

<FONT class='mainFont'>
  <CENTER>
    <!--<p><img src = 'images/apopic.jpg'></p>-->
    <br>
	<br>
	  <div class='headerTable'>
	  <b class='b1f'></b><b class='b2f'></b><b class='b3f'></b><b class='b4f'></b>
	  <div class='contentf'>
		  <div class = 'headerText'>
				Assign Midweek Credit to Users:
		  </div>";
		  
		  $sql = sprintf("SELECT `ID`, `Fname`, `TotCredit` FROM `users` ORDER BY `Fname` ASC");
		  $result= mysql_query($sql);
		  
		  for($i=0; $i<$num; $i+=1){
			$row=mysql_fetch_array($result);
			$id = $row["ID"];
			$fname = $row["Fname"];
			$preCred = $row["TotCredit"];
			$addVal = $_POST['add'.$i];
			
			if(strcmp($addVal,"")!=0){
				$newVal = $preCred + $addVal;
				$sql2="UPDATE `users` SET `TotCredit`='$newVal' WHERE `users`.`ID`='$id'";
				$result2=mysql_query($sql2);
				echo "<div>User $fname with id $id now has a total of $newVal midweek hours.</div>";				
			}
		  }
		  
		  echo "</div>
	  <b class='b4f'></b><b class='b3f'></b><b class='b2f'></b><b class='b1f'></b></div>
  </CENTER>
</FONT>
</body>
</html>
";

	require("footer.php");
	footer();

	mysql_close($link);
?>

		  